import {createRouter, createWebHashHistory} from 'vue-router'




let routes;

if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
    //移动端
    routes = [
        // 路由的默认路径
        {
            path:'/',
            redirect:"/Network"
        },
        {
            path: '/HelloWorld',
            name:'HelloWorld',
            component: () => import('../components/HelloWorld.vue')
        },
        {
            path: '/NewMy',
            name:'NewMy',
            component: () => import('../components/NewMy.vue')
        },
        {
            path: '/Network',
            name:'Network',
            component: () => import('../components/Network.vue')
        }, {
            path: '/',
            name:'Network',
            component: () => import('../components/ElementView.vue')
        }
    ]
} else {
    // pc端
    routes = [
        // 路由的默认路径
        {
            path:'/',
            redirect:"/Network"
        },
        {
            path: '/HelloWorld',
            component: () => import('../components/HelloWorld.vue')
        },
        {
            path: '/NewMy',
            name:'NewMy',
            component: () => import('../components/NewMy.vue')
        } ,
        {
            path: '/Network',
            name:'Network',
            component: () => import('../components/Network.vue')
        }, {
            path: '/ElementView',
            name:'elementView',
            component: () => import('../components/ElementView.vue')
        }
    
    ]
}


// 创建路由
const router = createRouter({
    // history: createWebHistory(),// 使用 history 模式路由
    history: createWebHashHistory(),// 使用 history 模式路由
    routes // 路由规则
})

export default router // 将路由对象暴露出去
